home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C10 / Local.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  590 b   |  29 lines

  1. //: C10:Local.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Static members & local classes
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. // Nested class CAN have static data members:
  11. class Outer {
  12.   class Inner {
  13.     static int i; // OK
  14.   };
  15. };
  16.  
  17. int Outer::Inner::i = 47;
  18.  
  19. // Local class cannot have static data members:
  20. void f() {
  21.   class Local {
  22.   public:
  23. //! static int i;  // Error
  24.     // (How would you define i?)
  25.   } x;
  26.  
  27. int main() { Outer x; f(); } ///:~
  28.